package org.kfive.nova.design.structture.flyweight;

import java.util.Hashtable;

/**
 * Created by admin on 2017-02-21.
 */
public class FlyweightFactory {
    private Hashtable<String,Flyweight> flyweights = new Hashtable();

    public Flyweight getFlyweight(String key){
        Flyweight flyweight = flyweights.get(key);
        if(flyweight!=null) {
            return flyweight;
        }else {
            flyweight = new ConcreteFlyweight(key);
            flyweights.put(key,flyweight);
            return flyweight;
        }
    }
}
